<layout name='Layout/layout_popup' />
<div class="popup">
	<div class="row-fluid title">
		<span>选择部门</span>
	</div>
	<div class="row-fluid operate">
		<div class="left">
			<a  onclick="save();" class="btn">确定</a>
		</div>
		<div class="right">
			<a  onclick="myclose();" class="btn">关闭</a>
		</div>
	</div>
	<div class="popup_tree_menu">
		<ul class="tree_menu">{$menu}</ul>
	</div>
</div>
<input type="hidden" name="val" id="val">
<input type="hidden" name="name" id="name">
<script type="text/javascript">
	function save(){
		if ($("#name").val().length > 0) {
			$("#dept_names", parent.document).val($("#name").val());
			$("#dept_ids", parent.document).val($("#val").val());
		} else {
			alert("请选择部门");
		}
		myclose();
	}


	$(document).ready(function() {
		$(".popup_tree_menu a").click(function(){
                         var dept_names = '';
                         var dept_ids = '';
			//$(".popup_tree_menu .tree_menu  a.active").removeClass("active");
			if($(this).attr('class') =='active'){
                             $(this).removeClass("active");
                        }else{
                              $(this).addClass("active");
                        }
                    $(".active").each(function(i,val){
                        dept_names +=$(this).children("span").text()+',';
                        dept_ids +=$(this).attr("node")+',';
                });
                    $("#val").val(dept_ids);
		    $("#name").val(dept_names);
		})
	}); 
</script>